home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2011 April / ME_2011_04.iso / [Video-Tutorial] / 9430830 / directory.swf / scripts / frame_1 / DoAction.as < prev   
Encoding:
Text File  |  2009-08-24  |  16.5 KB  |  503 lines

  1. function setStartScreen()
  2. {
  3.    header_op.textColor = _root.parseColor(_root.submenu_header_color);
  4.    header_op.text = _root.directory_label;
  5.    subheader_op.textColor = _root.parseColor(_root.submenu_subheader_color);
  6.    subheader_op.text = _root.directory_desc;
  7.    setRGB(header_line_mc,_root.parseColor(_root.seperator_line_color));
  8.    header_line_mc._alpha = Number(_root.seperator_line_alpha);
  9. }
  10. function renderContent()
  11. {
  12.    content_mc._visible = false;
  13.    removeContent();
  14.    entry_counter = 0;
  15.    y_pos = y_start_pos;
  16.    renderContentElements(_root.cd_content.firstChild.childNodes,[0],7,"1");
  17. }
  18. function renderContentElements(nodes_array, depth_array, x_pos, full_version)
  19. {
  20.    var _loc3_ = 0;
  21.    while(_loc3_ < nodes_array.length)
  22.    {
  23.       depth_array[depth_array.length - 1] += 1;
  24.       var _loc2_ = undefined;
  25.       if(depth_array.length <= 1)
  26.       {
  27.          _loc2_ = content_mc.attachMovie("entry_mc","entry_mc" + entry_counter,content_mc.getNextHighestDepth());
  28.          _loc2_.main = true;
  29.          if(_loc3_ > 0)
  30.          {
  31.             y_pos += main_entry_y_dis;
  32.          }
  33.       }
  34.       else
  35.       {
  36.          _loc2_ = content_mc.attachMovie("sub_entry_mc","entry_mc" + entry_counter,content_mc.getNextHighestDepth());
  37.       }
  38.       _loc2_._x = 0;
  39.       _loc2_._y = y_pos;
  40.       _loc2_.id = entry_counter;
  41.       entry_counter++;
  42.       _loc2_.node_type = nodes_array[_loc3_].attributes.type;
  43.       _loc2_.entry_name = nodes_array[_loc3_].attributes.name;
  44.       if(nodes_array[_loc3_].attributes.cd == "0" || full_version == "0")
  45.       {
  46.          if(nodes_array[_loc3_].attributes.cd == "0")
  47.          {
  48.             _loc2_.entry_name += " (" + _root.demo_only_sentence + ")";
  49.          }
  50.          _loc2_._alpha = 50;
  51.          _loc2_.bg_mc._visible = false;
  52.          _loc2_.enabled = false;
  53.          _loc2_.video_progress_mc._visible = false;
  54.       }
  55.       _loc2_.teaser = nodes_array[_loc3_].attributes.teaser;
  56.       if(nodes_array[_loc3_].attributes.length != "" && nodes_array[_loc3_].attributes.length != undefined)
  57.       {
  58.          if(_loc2_.node_type == "menu")
  59.          {
  60.             _loc2_.teaser += "\n\n" + _root.total_duration_desc + ": " + nodes_array[_loc3_].attributes.length;
  61.          }
  62.          else
  63.          {
  64.             _loc2_.teaser += "\n\n" + _root.duration_desc + ": " + nodes_array[_loc3_].attributes.length;
  65.          }
  66.       }
  67.       _loc2_.image = nodes_array[_loc3_].attributes.image;
  68.       _loc2_.movie = nodes_array[_loc3_].attributes.movie;
  69.       _loc2_.movie_name = nodes_array[_loc3_].attributes.movie.split(".")[0];
  70.       _loc2_.chapter_id = nodes_array[_loc3_].attributes.index;
  71.       _loc2_.movie_length = nodes_array[_loc3_].attributes.length;
  72.       _loc2_.chapter_op._x = x_pos;
  73.       setRGB(_loc2_.bg_mc,_root.parseColor(_root.submenu_rollover_color));
  74.       _loc2_.bg_mc._alpha = Number(_root.submenu_rollover_alpha);
  75.       _loc2_.bg_mc._visible = false;
  76.       _loc2_.chapter_op.autoSize = true;
  77.       _loc2_.chapter_op.textColor = _root.parseColor(_root.index_color);
  78.       _loc2_.chapter_op.text = nodes_array[_loc3_].attributes.index;
  79.       _loc2_.text_op.multiline = true;
  80.       _loc2_.text_op.wordWrap = true;
  81.       _loc2_.text_op.autoSize = true;
  82.       _loc2_.text_op._x = Math.round(_loc2_.chapter_op._x + Math.max(_loc2_.chapter_op.textWidth,30) + 5);
  83.       _loc2_.text_op.textColor = _root.parseColor(_root.submenu_color);
  84.       _loc2_.text_op.text = _loc2_.entry_name;
  85.       _loc2_.time_op.textColor = _root.parseColor(_root.submenu_color);
  86.       if(_loc2_.node_type == "movie")
  87.       {
  88.          _loc2_.time_op.text = nodes_array[_loc3_].attributes.length;
  89.          var _loc8_ = nodes_array[_loc3_].attributes.length.split(":");
  90.          var _loc5_ = Number(_loc8_[0]) * 60 + Number(_loc8_[1]);
  91.          if(isNaN(_loc5_))
  92.          {
  93.             _loc5_ = 0;
  94.          }
  95.          _loc2_.total_time = _loc5_;
  96.       }
  97.       else
  98.       {
  99.          _loc2_.time_op.text = "";
  100.       }
  101.       if(_loc2_.node_type == "movie")
  102.       {
  103.          _loc2_.symbol_mc.attachMovie("play_icon_mc","icon_mc",1);
  104.       }
  105.       else if(_loc2_.node_type == "menu")
  106.       {
  107.          _loc2_.bg_mc.useHandCursor = false;
  108.       }
  109.       else if(_loc2_.node_type == "toolbar")
  110.       {
  111.          _loc2_.symbol_mc.attachMovie("toolbar_icon_mc","icon_mc",1);
  112.       }
  113.       else if(_loc2_.node_type == "toolbar_advanced")
  114.       {
  115.          _loc2_.symbol_mc.attachMovie("toolbar_icon_mc","icon_mc",1);
  116.       }
  117.       else if(_loc2_.node_type == "mct")
  118.       {
  119.          _loc2_.symbol_mc.attachMovie("mct_icon_mc","icon_mc",1);
  120.       }
  121.       else if(_loc2_.node_type == "summary")
  122.       {
  123.          _loc2_.symbol_mc.attachMovie("summary_icon_mc","icon_mc",1);
  124.       }
  125.       _loc2_.symbol_mc.icon_mc._width = 16;
  126.       _loc2_.symbol_mc.icon_mc._height = 16;
  127.       _loc2_.onRelease = entryOnClick;
  128.       _loc2_.onRollOver = _loc2_.onDragOver = entryOnRollOver;
  129.       _loc2_.onRollOut = _loc2_.onDragOut = entryOnRollOut;
  130.       setItemSize(_loc2_);
  131.       setRGB(_loc2_.video_progress_mc.progress_bar_mc,_root.parseColor(_root.directory_progress_bar_seen_color));
  132.       setRGB(_loc2_.video_progress_mc.total_bar_mc,_root.parseColor(_root.directory_progress_bar_total_color));
  133.       setVideoProgress(_loc2_);
  134.       y_pos += Math.round(_loc2_._height + entry_y_dis);
  135.       if(nodes_array[_loc3_].hasChildNodes())
  136.       {
  137.          var _loc7_ = nodes_array[_loc3_].attributes.cd;
  138.          if(full_version == "0")
  139.          {
  140.             _loc7_ = "0";
  141.          }
  142.          renderContentElements(nodes_array[_loc3_].childNodes,depth_array.concat([0]),_loc2_.text_op._x,_loc7_);
  143.       }
  144.       _loc3_ = _loc3_ + 1;
  145.    }
  146.    if(depth_array.length == 1)
  147.    {
  148.       content_mc.attachMovie("place_holder_mc","place_holder_mc",content_mc.getNextHighestDepth());
  149.       content_mc.place_holder_mc._y = y_pos;
  150.       content_mc._visible = true;
  151.       mc_scroller.targetWidth = Math.round(content_mc._width);
  152.       mc_scroller.targetHeight = Math.round(content_mc._height);
  153.    }
  154.    content_mc.cacheAsBitmap = true;
  155. }
  156. function setVideoProgress(entry)
  157. {
  158.    if(entry.node_type == "movie")
  159.    {
  160.       if(!isNaN(v2b_so.data[entry.movie_name + "_data"].seen_time))
  161.       {
  162.          var _loc3_ = v2b_so.data[entry.movie_name + "_data"].seen_time;
  163.          var _loc4_ = entry.total_time;
  164.          var _loc1_ = Math.round(100 * _loc3_ / _loc4_);
  165.          if(_loc1_ < 0 || isNaN(_loc1_))
  166.          {
  167.             _loc1_ = 0;
  168.          }
  169.          else if(_loc1_ > 100)
  170.          {
  171.             _loc1_ = 100;
  172.          }
  173.          entry.video_progress_mc.progress_bar_mc._xscale = _loc1_;
  174.       }
  175.       else
  176.       {
  177.          entry.video_progress_mc.progress_bar_mc._xscale = 0;
  178.       }
  179.    }
  180.    else
  181.    {
  182.       entry.video_progress_mc._visible = false;
  183.    }
  184. }
  185. function reRenderVideoProgress()
  186. {
  187.    var _loc1_ = 0;
  188.    while(_loc1_ < entry_counter)
  189.    {
  190.       var _loc2_ = content_mc["entry_mc" + _loc1_];
  191.       setVideoProgress(_loc2_);
  192.       _loc1_ = _loc1_ + 1;
  193.    }
  194. }
  195. function setItemSize(item_mc)
  196. {
  197.    item_mc.bg_mc._width = max_content_width;
  198.    item_mc.symbol_mc._x = max_content_width - 25;
  199.    item_mc.time_op._x = item_mc.symbol_mc._x - 70;
  200.    item_mc.video_progress_mc._x = max_content_width - 130;
  201.    item_mc.text_op._width = item_mc.video_progress_mc._x - 25 - item_mc.text_op._x;
  202.    if(item_mc.main)
  203.    {
  204.       item_mc.bg_mc._height = Math.round(item_mc.text_op._y + item_mc.text_op.textHeight + 4);
  205.    }
  206.    else
  207.    {
  208.       item_mc.bg_mc._height = Math.round(item_mc.text_op._y + item_mc.text_op.textHeight + 4);
  209.    }
  210. }
  211. function entryOnClick()
  212. {
  213.    if(this.node_type == "movie")
  214.    {
  215.       startVideo(this.entry_name,this.movie,this.chapter_id);
  216.    }
  217.    else if(this.node_type == "toolbar")
  218.    {
  219.       local_root_mc._parent._parent.__lastactive.menu_item_rollover_mc._alpha = 0;
  220.       local_root_mc._parent._parent.__lastactive.__active = false;
  221.       local_root_mc._parent._parent.renderToolbar(this.movie,this.teaser,this.chapter_id,this.entry_name,true);
  222.    }
  223.    else if(this.node_type == "toolbar_advanced")
  224.    {
  225.       local_root_mc._parent._parent.__lastactive.menu_item_rollover_mc._alpha = 0;
  226.       local_root_mc._parent._parent.__lastactive.__active = false;
  227.       local_root_mc._parent._parent.renderAdvancedToolbar(this.movie,this.teaser,this.chapter_id,this.entry_name,true);
  228.    }
  229.    else if(this.node_type == "mct")
  230.    {
  231.       _root.renderMCT(this.movie);
  232.    }
  233.    else if(this.node_type == "summary")
  234.    {
  235.       local_root_mc._parent._parent.__lastactive.menu_item_rollover_mc._alpha = 0;
  236.       local_root_mc._parent._parent.__lastactive.__active = false;
  237.       local_root_mc._parent._parent.renderSummary(this.movie,this.teaser,this.chapter_id,this.entry_name,true);
  238.    }
  239. }
  240. function entryOnRollOver()
  241. {
  242.    roll_over_id = this.id;
  243.    this.bg_mc._visible = true;
  244.    this.text_op.textColor = _root.parseColor(_root.submenu_rollover_color);
  245.    this.time_op.textColor = _root.parseColor(_root.submenu_rollover_color);
  246.    var _loc3_ = {x:this.symbol_mc._x - 4,y:0};
  247.    this.localToGlobal(_loc3_);
  248.    local_root_mc.globalToLocal(_loc3_);
  249.    if(this.node_type == "movie")
  250.    {
  251.       _root.toolTip(_root.movie_tooltip,local_root_mc,"right",- Math.round(_loc3_.x),- Math.round(_loc3_.y));
  252.    }
  253.    else if(this.node_type != "menu")
  254.    {
  255.       if(this.node_type == "toolbar")
  256.       {
  257.          _root.toolTip(_root.toolbar_tooltip,local_root_mc,"right",- Math.round(_loc3_.x),- Math.round(_loc3_.y));
  258.       }
  259.       else if(this.node_type == "mct")
  260.       {
  261.          _root.toolTip(_root.mct_tooltip,local_root_mc,"right",- Math.round(_loc3_.x),- Math.round(_loc3_.y));
  262.       }
  263.       else if(this.node_type == "summary")
  264.       {
  265.          _root.toolTip(_root.summary_tooltip,local_root_mc,"right",- Math.round(_loc3_.x),- Math.round(_loc3_.y));
  266.       }
  267.    }
  268.    teaser_delay = setTimeout(local_root_mc._parent._parent,"renderTeaser",teaser_timeout,this.entry_name,this.teaser,this.chapter_id,this.image);
  269. }
  270. function entryOnRollOut()
  271. {
  272.    _root.killToolTip();
  273.    clearInterval(teaser_delay);
  274.    local_root_mc._parent._parent.destroyTeaser();
  275.    this.bg_mc._visible = false;
  276.    this.text_op.textColor = _root.parseColor(_root.submenu_color);
  277.    this.time_op.textColor = _root.parseColor(_root.submenu_color);
  278.    this.date_op.textColor = _root.parseColor(_root.submenu_color);
  279. }
  280. function startVideo(movie_name, movie, chapter)
  281. {
  282.    var _loc3_ = chapter.split(".");
  283.    if(_loc3_.length > 0 && isNaN(Number(_loc3_[_loc3_.length - 1])))
  284.    {
  285.       _loc3_.splice(_loc3_.length - 1,1);
  286.    }
  287.    var _loc4_ = _root.cd_content.firstChild;
  288.    if(_loc3_.length > 1)
  289.    {
  290.       var _loc2_ = 0;
  291.       while(_loc2_ < _loc3_.length - 1)
  292.       {
  293.          _loc4_ = _loc4_.childNodes[_loc3_[_loc2_] - 1];
  294.          _loc2_ = _loc2_ + 1;
  295.       }
  296.    }
  297.    _root.renderVideoBookmark(_loc4_,movie,movie_name,undefined);
  298. }
  299. function removeContent()
  300. {
  301.    for(var _loc1_ in content_mc)
  302.    {
  303.       content_mc[_loc1_].removeMovieClip();
  304.    }
  305. }
  306. function navigationButton_onRollOver()
  307. {
  308.    this.btn_rollover_mc._alpha = 100;
  309. }
  310. function navigationButton_onRollOut()
  311. {
  312.    this.btn_rollover_mc._alpha = 0;
  313. }
  314. function setVisibility(value)
  315. {
  316.    if(value)
  317.    {
  318.       reRenderVideoProgress();
  319.       Mouse.removeListener(ftScrollBarMouseListener);
  320.       Mouse.addListener(ftScrollBarMouseListener);
  321.       this._visible = value;
  322.       if(local_setpos_changelog != _root.setpos_changelog)
  323.       {
  324.          mc_scroller._visible = false;
  325.          setLocalPos();
  326.          init_scroller_delay = setTimeout(setScrollerVisible,250);
  327.       }
  328.    }
  329.    else
  330.    {
  331.       Mouse.removeListener(ftScrollBarMouseListener);
  332.       this._visible = value;
  333.    }
  334. }
  335. function setLocalPos()
  336. {
  337.    if(local_root_mc._visible)
  338.    {
  339.       if(local_test)
  340.       {
  341.          parent_container_width = Stage.width;
  342.          parent_container_height = Stage.height;
  343.       }
  344.       else
  345.       {
  346.          parent_container_width = _root.content_pos_mc.content_panel_mc._width - 535;
  347.          parent_container_height = _root.content_pos_mc.content_panel_mc._height;
  348.       }
  349.       max_content_width = Math.floor(parent_container_width - 40);
  350.       visible_scroller_height = Math.floor(parent_container_height - mc_scroller._y);
  351.       mc_scroller.viewAreaWidth = parent_container_width - 36;
  352.       mc_scroller.viewAreaHeight = Math.floor(visible_scroller_height);
  353.       mc_scroller._x = parent_container_width - 16;
  354.       mc_scroller.setSize(15,visible_scroller_height - 1);
  355.       header_op._width = parent_container_width - 2 * header_op._x;
  356.       subheader_op._width = header_op._width;
  357.       header_line_mc._width = parent_container_width - 2 * header_line_mc._x;
  358.       clearInterval(item_pos_delay);
  359.       item_pos_delay = setTimeout(setItemPos,200);
  360.       local_setpos_changelog = _root.setpos_changelog;
  361.    }
  362. }
  363. function updateScroller()
  364. {
  365.    if(visible_scroller_height < content_mc._height || mc_scroller.visible)
  366.    {
  367.       mc_scroller.setSize(15,visible_scroller_height - 1);
  368.    }
  369.    clearInterval(update_scroller_delay);
  370. }
  371. function setItemPos()
  372. {
  373.    var _loc3_ = y_start_pos;
  374.    var _loc4_ = content_mc.cacheAsBitmap;
  375.    content_mc.cacheAsBitmap = false;
  376.    var _loc2_ = 0;
  377.    while(_loc2_ < entry_counter)
  378.    {
  379.       var _loc1_ = content_mc["entry_mc" + _loc2_];
  380.       setItemSize(_loc1_);
  381.       if(_loc1_.main && _loc2_ > 0)
  382.       {
  383.          _loc3_ += main_entry_y_dis;
  384.       }
  385.       _loc1_._y = _loc3_;
  386.       _loc3_ += Math.round(_loc1_._height + entry_y_dis);
  387.       _loc2_ = _loc2_ + 1;
  388.    }
  389.    content_mc.place_holder_mc._y = _loc3_;
  390.    content_mc.cacheAsBitmap = _loc4_;
  391.    mc_scroller.targetWidth = Math.round(content_mc._width);
  392.    mc_scroller.targetHeight = Math.round(content_mc._height);
  393. }
  394. function createDateString(_date)
  395. {
  396.    var _loc1_ = "";
  397.    if(_date.getDate() >= 10)
  398.    {
  399.       _loc1_ += String(_date.getDate()) + ".";
  400.    }
  401.    else
  402.    {
  403.       _loc1_ += "0" + String(_date.getDate()) + ".";
  404.    }
  405.    if(_date.getMonth() >= 10)
  406.    {
  407.       _loc1_ += String(_date.getMonth()) + ".";
  408.    }
  409.    else
  410.    {
  411.       _loc1_ += "0" + String(_date.getMonth()) + ".";
  412.    }
  413.    _loc1_ += String(_date.getFullYear());
  414.    return _loc1_;
  415. }
  416. function createTimeString(_sec)
  417. {
  418.    var _loc1_ = "";
  419.    var _loc2_ = Math.floor(_sec / 60);
  420.    var _loc3_ = _sec - _loc2_ * 60;
  421.    if(_loc2_ >= 10)
  422.    {
  423.       _loc1_ += String(_loc2_) + ":";
  424.    }
  425.    else
  426.    {
  427.       _loc1_ += "0" + String(_loc2_) + ":";
  428.    }
  429.    if(_loc3_ >= 10)
  430.    {
  431.       _loc1_ += String(_loc3_);
  432.    }
  433.    else
  434.    {
  435.       _loc1_ += "0" + String(_loc3_);
  436.    }
  437.    return _loc1_;
  438. }
  439. function setRGB(mc, color)
  440. {
  441.    var _loc1_ = new flash.geom.ColorTransform();
  442.    _loc1_.rgb = color;
  443.    var _loc2_ = new flash.geom.Transform(mc);
  444.    _loc2_.colorTransform = _loc1_;
  445. }
  446. function setScrollerVisible()
  447. {
  448.    mc_scroller._visible = true;
  449.    clearInterval(init_scroller_delay);
  450. }
  451. function setTextScoller()
  452. {
  453.    info_mc.text_scroller.enabled = true;
  454.    info_mc.text_scroller._visible = true;
  455.    info_mc.text_scroller._x = info_mc.bm_text_bg_mc._x + info_mc.bm_text_bg_mc._width - 16;
  456.    info_mc.text_scroller._y = info_mc.bm_text_bg_mc._y + 2;
  457. }
  458. var local_root_mc = this;
  459. var local_test = false;
  460. var contPath = "config/content.xml";
  461. var roll_over_id = -1;
  462. var local_setpos_changelog = -1;
  463. var entry_counter;
  464. var y_start_pos = 27;
  465. var entry_y_dis = 3;
  466. var main_entry_y_dis = 22;
  467. var parent_container_width = 1025;
  468. var parent_container_heigt = 626;
  469. var max_content_width = 720;
  470. var teaser_delay;
  471. var update_scroller_delay;
  472. var init_scroller_delay;
  473. var teaser_timeout = 250;
  474. var ftScrollBarMouseListener = new Object();
  475. var visible_scroller_height;
  476. var masterPanelListener = new Object();
  477. var v2b_so = SharedObject.getLocal(_root.so_name,"/");
  478. mc_scroller._visible = false;
  479. var y_pos = y_start_pos;
  480. ftScrollBarMouseListener.onMouseWheel = function(delta, scrollTarget)
  481. {
  482.    if(local_root_mc._visible && mc_scroller.enabled)
  483.    {
  484.       if(mc_scroller.oSipDWs.hitTest(_root._xmouse,_root._ymouse,false))
  485.       {
  486.          var _loc3_ = Math.floor(parent_container_height - mc_scroller._y);
  487.          var _loc2_ = Math.ceil(2500 / (content_mc._height - _loc3_));
  488.          if(_loc2_ > 0)
  489.          {
  490.             if(delta < 1)
  491.             {
  492.                mc_scroller.scrollPercentage = Math.min(100,mc_scroller.scrollPercentage + _loc2_);
  493.             }
  494.             else
  495.             {
  496.                mc_scroller.scrollPercentage = Math.max(0,mc_scroller.scrollPercentage - _loc2_);
  497.             }
  498.          }
  499.       }
  500.    }
  501. };
  502. Mouse.addListener(ftScrollBarMouseListener);
  503.